package ui;

import bean.User;
import framework.BeanFactory;
import service.UserService;
import service.impl.UserServiceImpl;
import utils.BusinessException;

/*用户注册*/
public class RegisterClass extends BaseClass{

    private UserService userService;

    public RegisterClass() {
        userService = ((UserService) beanFactory.getBean("userService"));
    }

    public void register() throws BusinessException {
        /*输入用户名和密码*/
        println(getString("input.username"));
        String username = input.nextLine();
        println(getString("input.password"));
        String password = input.nextLine();

        //注册一个用户对象
        User user = new User(username, password);
        //UserService userService = new UserServiceImpl(); 不需要依赖类了，直接用工厂配置
        userService.register(user);
    }
}
